# coding: utf-8

import os
import time

import redis

PATH = os.path.dirname(os.path.abspath(__file__))


RESULT_PATH = '/home/tf/result_data/'
# login timeout
LOGIN_TIMEOUT = 300

# 采集脚本日志存在目录
LOG_DIR = os.path.join(PATH, 'logs')

# redis settings
REDIS_HOST = "127.0.0.1"
REDIS_PORT = 6379

# redis instance
redis_pool = redis.ConnectionPool(host=REDIS_HOST, port=REDIS_PORT,
                                  decode_responses=True)
redis_instance = redis.Redis(connection_pool=redis_pool)

# mysql
MYSQL_HOST = '127.0.0.1'
MYSQL_PORT = '3306'
MYSQL_USERNAME = 'root'
MYSQL_PASSWORD = 'tf123456'
MYSQL_DB = "youtobe"

# start container
_c_name = round(time.time())
START_CONTAINER = f"docker run -d --name {_c_name} --restart always  -e " \
                  "VNCPASSWD=  -e ROOT_PASSWORD=root@123 -e " \
                  "http_proxy=http://192.168.65.128:7890  -e " \
                  "https_proxy=http://192.168.65.128:7890  -e " \
                  "no_proxy=localhost,127.0.0.1  -e DISPLAY=:0.0  " \
                  "-p {port}:6080 " \
                  "-v /home/tf/.config/google-chrome:/home  xxx1:latest " \
                  "bash -c \"java -Dwebdriver.chrome.driver=/usr/bin/chromedriver" \
                  " -Dwebdriver.chrome.bin=/usr/bin/chrome -jar " \
                  "/root/selenium-server-4.25.0.jar node" \
                  " --hub http://192.168.65.128:4444 & /opt/start.sh \""

# chrome
USR_DATA_DIR = "/root/.config/google-chrome"
#USR_DATA_DIR = ""

REMOTE_DRIVER_URL = 'http://127.0.0.1:4444/wd/hub'
